<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="/layui/css/template.css">
<link rel="stylesheet" href="/plugins/powerful-album-view/dist/viewer.css">
<div class="site-content">
    <fieldset class="layui-elem-field">
        <legend>
            <button class="layui-btn layui-btn-sm" id="uploadFile"><i class="layui-icon layui-icon-upload-drag"></i>上传本地档案</button>
        <#--<#if baseFileInfoList??>-->
            <#--<button class="layui-btn layui-bg-red layui-btn-sm batchDownFile" id="downloadFile">-->
                <#--<i class="layui-icon layui-icon-download-circle"></i>下载档案-->
            <#--</button>-->
        <#--</#if>-->
        </legend>
        <div class="layui-field-box">
            <div class="layui-fluid">
                <div class="layui-row layui-col-space30 docs-pictures">
                <#if baseFileInfoList??>
                    <#list baseFileInfoList as fileInfo>
                        <div class="layui-col-sm4">
                            <div class="cmdlist-container">
                                <a href="javascript:void(0);">
                                    <img data-original="${fileInfo.filePath}" src="${fileInfo.smallPic}" id="${fileInfo.fileName}">
                                </a>
                                <a href="javascript:;">
                                    <div class="cmdlist-text">
                                        <p class="info">${fileInfo.fileName}</p>
                                        <div class="price">
                                            <p style="padding-bottom: 5px;">
                                            <div class="layui-btn-group">
                                                <button class="layui-btn layui-btn-primary layui-btn-xs toolButton"
                                                        id="editButton" data-title="修改" fileInfoId="${fileInfo.id}"><i
                                                        class="layui-icon"></i></button>
                                                <button class="layui-btn layui-btn-primary layui-btn-xs toolButton"
                                                        id="delButton" data-title="删除" fileInfoId="${fileInfo.id}"><i
                                                        class="layui-icon"></i></button>
                                            </div>
                                            <span class="flow x-right">${fileInfo.uploadDate?string('yyyy-MM-dd HH:mm')}</span>
                                        </div>
                                    </div>
                                </a>
                            </div>
                        </div>
                    </#list>
                </#if>
                </div>
            </div>
        </div>
    </fieldset>
</div>
<script src="/plugins/powerful-album-view/assets/js/jquery.min.js" charset="utf-8"></script>
<script src="/plugins/powerful-album-view/dist/viewer.js" charset="utf-8"></script>
<script src="/plugins/powerful-album-view/assets/js/main.js" charset="utf-8"></script>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(['upload', 'jmdf', 'layer'], function () {
        var $ = layui.jquery, upload = layui.upload, jmdf = layui.jmdf, layer = layui.layer;

        //拖拽上传
        upload.render({
            elem: '#uploadFile'
            , url: 'uploadSaveFile'
            , accept: 'file'   //允许上传文件类型（所有）
            , exts: '${fileMap["文件类型"]}'   //允许上传文件后缀名
            , size: ${fileMap["文件大小"]}    //允许上传文件大小
            , multiple: true
            , drag: true
            , data: {
                width: '120',
                height: '120',
                contractId: '${contract.id?c}',
                fileCategory: '${fileCategory}',
                myDate: new Date().getTime()
            }
            , before: function (object) {
                layer.msg('上传中...', {icon: 16, shade: 0.01, time: 200000});
            }
            , done: function (result) {//必须接收json格式参数，否则一致报接口异常错
                if (result.success == "true") {
                    showRight("${fileCategory}");
                }
                layer.close(layer.index);
            }
        });


        $(".batchDownFile").click(function () {
            location.href = "batchDownFile?contractId=${contract.id}&fileCategory=${fileCategory}";
        });

        $(".toolButton").click(function () {
            var fileInfoId = $(this).attr("fileInfoId");
            var id = $(this).attr("id");
            if (id == "editButton") {
                jmdf.minForm("fileInfoForm?fileInfoId=" + fileInfoId,"800px","300px");
            } else if (id == "delButton") {
                layer.open({
                    title: false, shade: 0.5, content: '确定要删除该档案图片吗？', btn: ['确定', '取消'], closeBtn: 0, btnAlign: 'c'
                    , yes: function (index) {
                        $.get("deleteFileInfo", {fileInfoId: fileInfoId, _t: new Date().getTime()}, function (data) {
                            if (data.code == "0000") {//成功
                                layer.msg(data.message, {anim: 0, icon: 1, time: 500}, function () {
                                    showRight("${fileCategory}");
                                });
                            } else {//失败
                                layer.msg(data.message, {anim: 6, icon: 2}, function () {
                                });
                            }
                        });
                    }
                });
            }
        });
    });

</script>
